@isTest

private class iFulfillCreateTaskTest{

/** Class Name: iFulfillCreateTaskTest
* Author: Accenture
* Date: 12-Jul-2011 
* Requirement/Project Name: iFulfill 
* Requirement Description: Creates tasks for escalated,outed and live Fulfillment ITems
**/
  static testMethod void createTask()
  {     
          
    list<Fullfilment_Item__c> updatedFItems = new list<Fullfilment_Item__c>();
    Map<Id,Fullfilment_Item__c>  mapFI = new Map<Id,Fullfilment_Item__c>();
    iFulfillCreateTask.setRecursive(true); 
    Profile p = [select id from profile where name='System Administrator']; 
    User u = new User(alias = 'usrrerd', email='sfuser@salesforce.com', 
    emailencodingkey='UTF-8', lastname='sfuser', languagelocalekey='en_US', 
    localesidkey='en_US', profileid = p.Id, 
    timezonesidkey='America/Los_Angeles', username='sfusr@salesforce.com');
    insert u; 
    User u1 = new User(alias = 'usrrerd1', email='sfuser1@salesforce.com', 
    emailencodingkey='UTF-8', lastname='sfuser1', languagelocalekey='en_US', 
    localesidkey='en_US', profileid = p.Id, 
    timezonesidkey='America/Los_Angeles', username='sfusr1@salesforce.com');
    insert u1;           
     Fullfilment_Item__c FI1 = new Fullfilment_Item__c(Escalated__c=false,AreaZone__c='1',Attribute_Code__c='123',ownerid=u.ID);
     insert FI1;
     Fullfilment_Item__c FI2= new Fullfilment_Item__c(Escalated__c=false,Status__c='Open',AreaZone__c='3',Attribute_Code__c='12345',ownerid=u1.ID);
     insert FI2;
     Fullfilment_Item__c FI3= new Fullfilment_Item__c(Status__c='Open',AreaZone__c='3',Attribute_Code__c='123453');
     insert FI3;
     list<Fullfilment_Item__c> oldList = [select id,status__c,Escalated__c,ownerid from Fullfilment_Item__c where id in (:FI1.id,:FI2.id,:FI3.id)];     
     mapFI.put(FI1.id,FI1); 
     mapFI.put(FI2.id,FI2); 
     mapFI.put(FI3.id,FI3); 
     
     Fullfilment_Item__c F1=[select id,status__c,Escalated__c,ownerid from Fullfilment_Item__c where id= :FI1.id];
     F1.Escalated__c=true;
     F1.Escalation_Notes__c ='Testing';
     F1.Escalation_Reason__c ='Initial Fulfillment Error';
     F1.ownerID = u.id;
     
     Update F1; 
     updatedFItems.add(F1);            
     Fullfilment_Item__c F2=[select id,status__c,Escalated__c,ownerid from Fullfilment_Item__c where id= :FI2.id];
     F2.Status__c= 'Outed';
     F2.ownerID = u.id;
     Update F2;
     updatedFItems.add(F2);
     Fullfilment_Item__c F3=[select id,status__c,Escalated__c,ownerid from Fullfilment_Item__c where id= :FI3.id];
     F3.Status__c= 'Live';
     F3.ownerID = u.id;
     
     Update F3;  
     updatedFItems.add(F3);            
     iFulfillCreateTask.createTask(updatedFItems,mapFI); 
  }
  
  static testMethod void reminderevents ()
  {
     list<Fullfilment_Item__c> updatedFItems = new list<Fullfilment_Item__c>();
     Profile p = [select id from profile where name='System Administrator']; 
    User u = new User(alias = 'usrrerd', email='sfuser@salesforce.com', 
    emailencodingkey='UTF-8', lastname='sfuser', languagelocalekey='en_US', 
    localesidkey='en_US', profileid = p.Id, 
    timezonesidkey='America/Los_Angeles', username='sfusr@salesforce.com');
    insert u;
   Fullfilment_Item__c FI1 = new Fullfilment_Item__c(Content_Version__c=1,Content_Last_Modified_By__c='Test',ownerid=u.ID);
   updatedFItems.add(FI1);
  iFulfillCreateTask.reminderevents(updatedFItems);

  }

  
}